package com.sqf.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sqf.dao.GoodsDao;
import com.sqf.entity.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ServiceImpl implements GoodsService{

    @Autowired
    GoodsDao goodsDao;


    @Override
    public PageInfo<Goods> list(Goods goods, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo,pageSize);

        List<Goods> list = goodsDao.list(goods);
        return new PageInfo<>(list);
    }

    @Override
    public List<Goods> list1() {
        List<Goods> goods = goodsDao.list1();
        return goods;
    }

    @Override
    public boolean delete(Integer id) {

        int i = goodsDao.delete(id);
        if(i>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Goods Byid(Integer id) {
        Goods byid = goodsDao.Byid(id);

        return byid;
    }
}
